$ONTEXT
David Morton
	A capacity expansion planning model under uncertainty. There are two types
	of uncertainty: (i) demand and (ii) generator availability. In the first
	stage, capacity is allocated to two generators. In the second stage, a
	transportation problem is solved to send electricity from the generators to
	three demand sites. If the available capacity is not sufficient to meet the
	demand then we must purchase electricity from an outside source (subcontract)
	to satisfy the demand.
$OFFTEXT

$TITLE capacity expansion planning problem

$OFFUPPER OFFSYMXREF OFFSYMLIST
$INLINECOM { }

OPTIONS ITERLIM = 10000, RESLIM = 10000, LIMROW = 0,
	LIMCOL = 0, SYSOUT = OFF, SOLPRINT = OFF,
	LP = CPLEX, OPTCR = 0.00001;

SETS
	I generators /I1*I2/
	J demand sites /J1*J3/;

* define the demand
PARAMETER DEMAND(J)
	  /
	  J1 1000
	  J2 1000
	  J3 1100
	  /;

* capacity unit investment cost
PARAMETER KINVEST(I)
	  /I1 400.0
	   I2 350.0 /;

* transportation cost
TABLE CTRANS(I,J)
     J1 J2 J3
I1 4.3 2.0 0.5
I2 7.7 3.0 1.0
;

* subcontracting cost
SCALAR SUBCON /6000.0/;

* maximum investment
SCALAR BMAXINV /10000.0/;

VARIABLES X(I) {first stage capacity allocation}
	  Y(I,J) {second stage transportation vars}
	  S(J) {second stage subcontracting vars}
	  Z;
POSITIVE VARIABLES X,Y,S;

EQUATIONS
	UTILITY {the objective}
	INVCAP {first stage capacity constraint}
	SUPPLY(I) {don’t use more supply than available}
	LOAD(J){satisfy demand}
	;
* objective is sum of first stage investment cost and expected
* second stage transportation and subcontracting cost
UTILITY .. Z =E= SUM(I,KINVEST(I)*X(I)) +
	   SUM((I,J),CTRANS(I,J)*Y(I,J)) +
	   SUM(J,SUBCON*S(J)) ;
* we can invest no more than BMAXINV units of capacity
INVCAP .. SUM(I, X(I)) =L= BMAXINV ;
* the second stage generation bounds
SUPPLY(I) .. SUM(J,Y(I,J)) - X(I) =L= 0.0;
* the second stage demand constraints
LOAD(J) .. SUM(I,Y(I,J)) + S(J) =G= DEMAND(J) ;
MODEL CAPACITY /UTILITY, INVCAP, SUPPLY, LOAD/;
SOLVE CAPACITY USING LP MINIMIZING Z;
DISPLAY X.L, Z.L;